/**
 * Created by shudong.msd(风骐) on 2016/4/17.
 */
app.directive('pwCheck', function () {
    return {
        require: 'ngModel',
        link: function (scope, elem, attrs, ctrl) {
            var firstPassword = '#' + attrs.pwCheck;
            elem.add(firstPassword).on('blur', function () {
                var v = elem.val()==$(firstPassword).val();
                if(attrs.pwCheck=='oldPassword')v = !v;
                ctrl.$setValidity('pwMatch', v);

                if(!scope.$$phase) {
                    scope.$apply();
                }
            });
        }
    };
});